
package test.consql;
import javax.naming.*;
import javax.sql.*;
import java.sql.*; 
public class Tom{
	public static void main(String args[])
	{
Connection conn=null;
Statement stmt=null;
ResultSet rs=null;
ResultSetMetaData md=null;
try
{
Context initCtx=new InitialContext();
DataSource ds=(DataSource)initCtx.lookup("java:comp/env/jdbc/quickstart");
if(ds!=null)
{

conn=ds.getConnection();
stmt=conn.createStatement();

rs=stmt.executeQuery("select top 5 * from users");
md=rs.getMetaData();

for(int i=0;i<md.getColumnCount();i++)
{

}while(rs.next())
{
System.out.println(rs.getString("username"));
}

conn.close();

}}
catch(Exception e)
{

System.out.println(e.toString());
}
}}